package com.situ.lession1226.service.impl;

import com.situ.lession1226.dao.RatingDAO;
import com.situ.lession1226.model.Rating;
import com.situ.lession1226.service.RatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class RatingServiceImpl implements RatingService {
    private RatingDAO dao;

    @Autowired
    public void setDao(RatingDAO dao) {
        this.dao = dao;
    }

//    @Override
//    public List<Rating> findAll(Integer id) {
//
//        //2.正常进行查询
//            List<Rating> Ratings = dao.findAllRatingByNewsId(id);
//
//            return Ratings;
//
//    }

    @Override
    public List<Rating> findBest() {
        List<Rating> Ratings = dao.findBest();

        return Ratings;

    }
    public void aver(Integer newid) {
        dao.aver(newid);
    }

    @Override
    public int deleteByIds(Integer[] ids) {
        return dao.deleteByIds(ids);
    }
    @Override
    public Rating findById(Integer id) {
        return dao.findById(id);
    }
    @Override
    public boolean save(Rating rating) {
        return dao.save(rating) > 0;
    }

    @Override
    public boolean haveaver(Integer newid) {
        if(dao.haveaver(newid).size()!=0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public void insertaver(Integer newid) {
        dao.insertaver(newid);
    }

}